
options decimals = 6;

sets
        t "time periods" /t1*t26/
        tp(t) /t1*t26/
        tpi(t) /t1/
        tfirst(t) "First time period"
        tlast(t) "Final time period"
        ind /i1*i22/
        ie(ind) "Energy Industries" /i1*i2,i5*i7/
        im(ind) "Material Industries" /i3,i4,i8*i22/
        oilgas(ind) "Oil&Gas Extraction" /i1/
        coal(ind) "Coal Mining" /i2/
        industrial(ind) "Industrial" /i1*i4,i8*i12/
        commercial(ind) "Commercial" /i13*i14,i16*i21/
        gov(ind) "Government" /i22/
        transportation(ind) "Transportation" /i15/
        elec(ind) "Elecric Power" /i5/ 
        ngd(ind) "Nat Gas Dist" /i6/
        refine(ind) "Refine" /i7/
        refine_n(ind) /i1*i6,i8*i22/
        primary(ind) "Primary Energy" /i1*i2/ 
        secondary(ind) "Secondary Energy" /i6*i7/ 
        durable(ind) "Durable Manuf" /i11/ 
        nondurable(ind)  "Non-durable Manuf" /i12/
        other(ind) /i3,i4,i8,i9,i10,i16/
        trade(ind) "Trade"  /i13,i14/
        it "iterations" /it1*it4/
        out /out1*out12/
        services(ind) /i17*i21/
;

tfirst(t) = yes$(ord(t) eq 1);
tlast(t) = yes$(ord(t) eq card(t));
alias (ind,ind2)
alias (ind,ind3)
alias(ie,ie2);
alias(im,im2);
alias(industrial,industrial2)
alias(commercial,commercial2)
alias(refine_n,refine_n2)

scalar
nt "Number of Periods" /26/
;


* DEFINE DEEP PARAMETERS
parameters
         beta "time preference" /.996/
         betat(t)
         chi "Frisch Elasticity of Labor Supply" /1/
         cost_fire "Firing Costs" /.001/
         delta(ind2,ind) "Kronecker Delta"
         tau "Nash bargaining weight" /.5/
         pi(ind) "Exogenous quit rate"
         pig "Government exogenous quit rate"
         pi_f(ind) "Foreign exogenous quit rate"
         pig_f "Foreign government exogenous quit rate"
         gamma "Curvature of matching function" /0.5/
         mu_e(ind,ind2) "Emissions factor"
         tau_l0 "Tax on Labor Income" /0.31/
         tau_p0 "Payroll tax" /0.06/
         sigma /1/
         sigmac "Elast. of subs. between cons. goods" /0.75/
         sig_e(ind) "Elast. of subs. between energy goods"
         sig_eg "Elast. of subs. between energy goods - gov"
         sig_m(ind) "Elast. of subs. between non-energy goods"
         sig_mg "Elast. of subs. between non-energy goods - gov"
         sig_v(ind) "Elast. of subs. between energy and non-energy goods"
         sig_vg "Elast. of subs. between energy and non-energy goods - gov"
         sig_y(ind) "Elast. of subs. between labor and inter. inputs"
         sig_yg "Elast. of subs. between labor and inter. inputs - gov"
         rho(ind)
         rhog

         sig_df(ind)
         sig_c(ind)
         sig_c_f(ind)

;


betat(t) = beta**(ord(t)-1);

sig_y(ind) = 0.5;
sig_e(ind) = 0.4;
sig_m(ind) = 0.6;
sig_v(ind) = 0.7;

sig_v('i5')  = 0.4;
sig_v('i6')  = 0.4;
sig_v('i7')  = 0.4;
sig_v('i8')  = 0.4;

sig_eg = 0.2;
sig_mg = 0.2;
sig_vg = 0.2;
sig_yg = 0.2;

rho(ind) = (sig_y(ind)-1)/sig_y(ind);
rhog = (sig_yg-1)/sig_yg;

sig_e(elec) = 1.5;

* Foreign and domestic sustituion elas for both production and consumption
sig_df(ind) = 1.5;
sig_c(ind) = 1.5;
sig_c_f(ind) = 1.5;



$INCLUDE HWC_JAERE_CAL_QFIX.gms



* DEFINE STEADY STATE CARBON PRICE

parameter
p_e0
tar_i2(ind)
gammay_ss_ct(ind)
gammay(ind,t)
gammav_ss(ind)
gammav(ind,t)
;

p_e0 = 0;
tar_i2(refine) = f_y0(refine)*sum(oilgas,mu_e(oilgas,refine));
gammay_ss_ct(ind) = gammay0.l(ind);
gammay(ind,t) = gammay0.l(ind);
gammav_ss(ind) = gammav0(ind);
gammav(ind,t) = gammav0(ind);


$INCLUDE HWC_JAERE_EQN_TRANS.gms




options decimals = 5;




* REPLICATE BASE CASE WITH P_E = 0;


options iterlim = 0;

p_e_ss(ind,ind2) = 0;
p_e_c_ss(ind) = 0;
p_e(ind,ind2,t) = 0;
p_e_c(ind,t) = 0;
sub_ss_ct.fx(ind) = 0;
sub.fx(ind,t) = 0;

tau_l.fx = tau_l0;

solve hwc_ss_ct using mcp ;



n0(ind) = n_ss_ct.l(ind);
ng0 = ng_ss_ct.l;
n0_f(ind) = n_f_ss_ct.l(ind);
ng0_f = ng_f_ss_ct.l;


solve hwc_trans_ct using mcp;



* SOLVE STEADY STATE WITH P_E>0
options iterlim = 100000000;

* Define steady state output parameters

parameter
utot_ss_ct
n_d
n_d_perc
n_ss_it
n_ss_ct_it

l_ss_ct
l_d
l_d_perc
h_d
h_d_perc
ng_d
ng_d_perc
lg_ss_ct
lg_d
lg_d_perc
hg_d
hg_d_perc
tlump_d
net_gross
crev_ss_ct
perc_e
perc_e_elec
perc_e_y
perc_l
perc_h
perc_n

tbal_ss_db
mc_ss_db
bc_ss_db
mc_ss_f_db
bc_ss_f_db
yg_ss_db
yg_ss_f_db
sub_ss_db

tbal_db
mc_db
bc_db
mc_f_db
bc_f_db
yg_db
yg_f_db

ndiff
ngdiff
nfdiff
nfgdiff

utot
utot_f
utot_diff
sub_it
tau_l_d

perc_l_new
perc_h_new
perc_n_new

l_ct
lg_ct
perct_l
perct_h
perct_w
perct_earn
;

* Define transition output parameters

p_e0 = 0;
loop(it,p_e0 = p_e0+10;

p_e_ss(ind,ind2) = p_e0;
p_e_c_ss(ind) = p_e0;
p_e(ind,ind2,t) = p_e0;
p_e_c(ind,t) = p_e0;






solve hwc_ss_CT using mcp   ;

p.l(ind,t) = p_ss_ct.l(ind);

p_c.l(ind,t) = p_c_ss_ct.l(ind);
p_cbar.l(t) = p_cbar_ss_ct.l;
exch.l(t) = exch_ss_ct.l;

sub.l(ind,t) = sub_ss_ct.l(ind);

p_f.l(ind,t) = p_f_ss_ct.l(ind);

p_c_f.l(ind,t) = p_c_f_ss_ct.l(ind);
p_cbar_f.l(t) = p_cbar_f_ss_ct.l;

lambda.l(t) = lambda_ss_ct.l;
lambda_f.l(t) = lambda_f_ss_ct.l;

lambdag.l(t) = lambdag_ss_ct.l;
lambdag_f.l(t) = lambdag_f_ss_ct.l;


cbar.l(t) = cbar_ss_ct.l;
c.l(ind,t) = c_ss_ct.l(ind);
cd.l(ind,t) = cd_ss_ct.l(ind);
cf.l(ind,t) = cf_ss_ct.l(ind);
m.l(t) = beta;
v_n.l(ind,t) = v_n_ss_ct.l(ind);
v_ng.l(t) = v_ng_ss_ct.l;
phibar.l(t) = phibar_ss_ct.l;


cbar_f.l(t) = cbar_f_ss_ct.l;
c_f.l(ind,t) = c_f_ss_ct.l(ind);
cd_f.l(ind,t) = cd_f_ss_ct.l(ind);
cf_f.l(ind,t) = cf_f_ss_ct.l(ind);
m_f.l(t) = beta;
v_n_f.l(ind,t) = v_n_f_ss_ct.l(ind);
v_ng_f.l(t) = v_ng_f_ss_ct.l;
phibar_f.l(t) = phibar_f_ss_ct.l;



w.l(ind,t) = w_ss_ct.l(ind);
h.l(ind,t) = h_ss_ct.l(ind);
w_f.l(ind,t) = w_f_ss_ct.l(ind);
h_f.l(ind,t) = h_f_ss_ct.l(ind);
wg.l(t) = wg_ss_ct.l;
hg.l(t) = hg_ss_ct.l;
wg_f.l(t) = wg_f_ss_ct.l;
hg_f.l(t) = hg_f_ss_ct.l;

vbar.l(ind,t) = vbar_ss_ct.l(ind);
j_n.l(ind,t) = j_n_ss_ct.l(ind);
f_l.l(ind,t) = f_l_ss_ct.l(ind);
f_v.l(ind,t) = f_v_ss_ct.l(ind);
vv.l(ind,t) = vv_ss_ct.l(ind);
io_id.l(ind,ind2,t) = io_id_ss_ct.l(ind,ind2);
io_if.l(ind,ind2,t) = io_if_ss_ct.l(ind,ind2);
cost_df.l(ind,ind2,t) = cost_df_ss_ct.l(ind,ind2);
cost_e.l(ind,t) = cost_e_ss_ct.l(ind);
io_ie.l(ie,ind,t) = io_ie_ss_ct.l(ie,ind);
cost_m.l(ind,t) = cost_m_ss_ct.l(ind);
io_im.l(im,ind,t) = io_im_ss_ct.l(im,ind);
cost_v.l(ind,t) = cost_v_ss_ct.l(ind);
io_ev.l(ind,t) = io_ev_ss_ct.l(ind);
io_mv.l(ind,t) = io_mv_ss_ct.l(ind);
iod.l(ind,ind2,t) = iod_ss_ct.l(ind,ind2);
iof.l(ind,ind2,t) = iof_ss_ct.l(ind,ind2);
y.l(ind,t) = y_ss_ct.l(ind);
prof.l(ind,t) = prof_ss_ct.l(ind);
fire.l(ind,t) = 0;
e.l(ind,t) = e_ss_ct.l(ind);
etot.l(t) = etot_ss_ct.l;

vbar_f.l(ind,t) = vbar_f_ss_ct.l(ind);
j_n_f.l(ind,t) = j_n_f_ss_ct.l(ind);
f_l_f.l(ind,t) = f_l_f_ss_ct.l(ind);
f_v_f.l(ind,t) = f_v_f_ss_ct.l(ind);
vv_f.l(ind,t) = vv_f_ss_ct.l(ind);
io_id_f.l(ind,ind2,t) = io_id_f_ss_ct.l(ind,ind2);
io_if_f.l(ind,ind2,t) = io_if_f_ss_ct.l(ind,ind2);
cost_df_f.l(ind,ind2,t) = cost_df_f_ss_ct.l(ind,ind2);
cost_e_f.l(ind,t) = cost_e_f_ss_ct.l(ind);
io_ie_f.l(ie,ind,t) = io_ie_f_ss_ct.l(ie,ind);
cost_m_f.l(ind,t) = cost_m_f_ss_ct.l(ind);
io_im_f.l(im,ind,t) = io_im_f_ss_ct.l(im,ind);
cost_v_f.l(ind,t) = cost_v_f_ss_ct.l(ind);
io_ev_f.l(ind,t) = io_ev_f_ss_ct.l(ind);
io_mv_f.l(ind,t) = io_mv_f_ss_ct.l(ind);
iod_f.l(ind,ind2,t) = iod_f_ss_ct.l(ind,ind2);
iof_f.l(ind,ind2,t) = iof_f_ss_ct.l(ind,ind2);
y_f.l(ind,t) = y_f_ss_ct.l(ind);
prof_f.l(ind,t) = prof_f_ss_ct.l(ind);
fire_f.l(ind,t) = 0;

vbarg.l(t) = vbarg_ss_ct.l;
cg_n.l(t) = cg_n_ss_ct.l;
f_lg.l(t) = f_lg_ss_ct.l;
f_vg.l(t) = f_vg_ss_ct.l;
vvg.l(t) = vvg_ss_ct.l;
io_idg.l(ind,t) = io_idg_ss_ct.l(ind);
io_ifg.l(ind,t) = io_ifg_ss_ct.l(ind);
cost_dfg.l(ind,t) = cost_dfg_ss_ct.l(ind);
cost_eg.l(t) = cost_eg_ss_ct.l;
io_ieg.l(ie,t) = io_ieg_ss_ct.l(ie);
cost_mg.l(t) = cost_mg_ss_ct.l;
io_img.l(im,t) = io_img_ss_ct.l(im);
cost_vg.l(t) = cost_vg_ss_ct.l;
io_evg.l(t) = io_evg_ss_ct.l;
io_mvg.l(t) = io_mvg_ss_ct.l;
gd.l(ind,t) = gd_ss_ct.l(ind);
gf.l(ind,t) = gf_ss_ct.l(ind);


vbarg_f.l(t) = vbarg_f_ss_ct.l;
cg_n_f.l(t) = cg_n_f_ss_ct.l;
f_lg_f.l(t) = f_lg_f_ss_ct.l;
f_vg_f.l(t) = f_vg_f_ss_ct.l;
vvg_f.l(t) = vvg_f_ss_ct.l;
io_idg_f.l(ind,t) = io_idg_f_ss_ct.l(ind);
io_ifg_f.l(ind,t) = io_ifg_f_ss_ct.l(ind);
cost_dfg_f.l(ind,t) = cost_dfg_f_ss_ct.l(ind);
cost_eg_f.l(t) = cost_eg_f_ss_ct.l;
io_ieg_f.l(ie,t) = io_ieg_f_ss_ct.l(ie);
cost_mg_f.l(t) = cost_mg_f_ss_ct.l;
io_img_f.l(im,t) = io_img_f_ss_ct.l(im);
cost_vg_f.l(t) = cost_vg_f_ss_ct.l;
io_evg_f.l(t) = io_evg_f_ss_ct.l;
io_mvg_f.l(t) = io_mvg_f_ss_ct.l;
gd_f.l(ind,t) = gd_f_ss_ct.l(ind);
gf_f.l(ind,t) = gf_f_ss_ct.l(ind);

phi_i.l(ind,t) = phi_i_ss_ct.l(ind);
q.l(ind,t) = q_ss_ct.l(ind);
theta_i.l(ind,t) = theta_i_ss_ct.l(ind);
n.l(ind,t) = n_ss_ct.l(ind);

phi_g.l(t) = phi_g_ss_ct.l;
qg.l(t) = qg_ss_ct.l;
theta_g.l(t) = theta_g_ss_ct.l;
ng.l(t) = ng_ss_ct.l;

thetatot.l(t) = thetatot_ss_ct.l;
ntot.l(t) = ntot_ss_ct.l;

phi_f.l(ind,t) = phi_f_ss_ct.l(ind);
q_f.l(ind,t) = q_f_ss_ct.l(ind);
theta_f.l(ind,t) = theta_f_ss_ct.l(ind);
n_f.l(ind,t) = n_f_ss_ct.l(ind);
phig_f.l(t) = phig_f_ss_ct.l;
qg_f.l(t) = qg_f_ss_ct.l;
thetag_f.l(t) = thetag_f_ss_ct.l;
ng_f.l(t) = ng_f_Ss_ct.l;
thetatot_f.l(t) = thetatot_f_ss_ct.l;
ntot_f.l(t) = ntot_f_ss_ct.l;

grev.l(t) = grev_ss_ct.l;
tau_l.l = tau_l0;
grev_f.l(t) = grev_f_ss_ct.l;
tlump_f.l(t) = tlump_f_ss_ct.l;

exports.l(ind,t) = exports_ss_ct.l(ind);
imports.l(ind,t) = imports_ss_ct.l(ind);







* SOLVE TRANSITION TO NEW STEADY STATE

n0(ind) = n_ss.l(ind);
ng0 = ng_ss.l;
n0_f(ind) = n_f_ss.l(ind);
ng0_f = ng_f_ss.l;


*tau_l.lo = 0.25;
*tau_l.up = 0.45;

fire.lo(ind,t)$(not tlast(t)) = 0;
fire.fx(ind,tlast) = 0;
vbar.lo(ind,t)$(not tlast(t)) = 0;
vbar_f.lo(ind,t)$(not tlast(t)) = 0;
vbarg.lo(t)$(not tlast(t)) = 0;
vbarg_f.lo(t)$(not tlast(t)) = 0;
vbar.fx(ind,'t25') = vbar_ss_ct.l(ind);
vbar_f.fx(ind,'t25') = vbar_f_ss_ct.l(ind);
vbarg.fx('t25') = vbarg_ss_ct.l;
vbarg_f.fx('t25') = vbarg_f_ss_ct.l;
q.lo(ind,t) = 0;
thetatot.lo(t) = 0.00001;
theta_g.lo(t) = 0.00001;
theta_i.lo(ind,t) = 0.00001;


p.fx('i22',t) = 1;
p_f.fx('i22',t) = 1;


*options iterlim = 0;

solve hwc_trans_ct using mcp;

* SAVE STEADY STATE OUTPUT

utot_ss_ct(it) = 1-ntot_ss_ct.l;

n_d(ind,it)= n_ss_ct.l(ind)-n_ss.l(ind);
n_d_perc(ind,it)= (n_ss_ct.l(ind)-n_ss.l(ind))/n_ss.l(ind);

n_ss_it(ind,it) = n_ss.l(ind);
n_ss_ct_it(ind,it) = n_ss_ct.l(ind);

ng_d(it)= ng_ss_ct.l-ng_ss.l;
ng_d_perc(it)= (ng_ss_ct.l-ng_ss.l)/ng_ss.l;

l_ss_ct(ind) = h_ss_ct.l(ind)*n_ss_ct.l(ind);
*(1-vbar_ss_ct.l(ind));
l_d(ind) = l_ss_ct(ind)-l_ss(ind);
l_d_perc(ind,it) = (l_ss_ct(ind)-l_ss(ind))/l_ss(ind);

l_ct(ind,t) = h.l(ind,t)*n.l(ind,t);
lg_ct(t) = hg.l(t)*ng.l(t);



lg_ss_ct = hg_ss_ct.l*ng_ss_ct.l;
*(1-vbarg_ss_ct.l);
lg_d = lg_ss_ct-lg_ss;
lg_d_perc(it) = (lg_ss_ct-lg_ss)/lg_ss;

h_d(ind,it) = h_ss_ct.l(ind) - h_ss.l(ind);
h_d_perc(ind,it) = (h_ss_ct.l(ind) - h_ss.l(ind))/h_ss.l(ind);

hg_d(it) = hg_ss_ct.l - hg_ss.l;
hg_d_perc(it) = (hg_ss_ct.l - hg_ss.l)/hg_ss.l;

tlump_d(it) = tlump_ss_ct.l - tlump_ss;


perc_e(it) = (etot_ss_ct.l-etot0)/etot0;
perc_e_elec(elec,it) = (e_ss_ct.l(elec) - e0(elec))/e0(elec);

perc_e_y(elec,it) = (e_ss_ct.l(elec)/y_ss_ct.l(elec) - e_y0(elec))/e_y0(elec);
perc_l(it) = (sum(ind,l_ss_ct(ind))+lg_ss_ct-sum(ind,l_ss(ind))-lg_ss)/(sum(ind,l_ss(ind))+lg_ss);
perc_h(it) = (sum(ind,n_ss.l(ind)*h_ss_ct.l(ind))+ng_ss.l*hg_ss_ct.l-sum(ind,n_ss.l(ind)*h_ss.l(ind))-ng_ss.l*hg_ss.l)/(sum(ind,n_ss.l(ind)*h_ss.l(ind))+ng_ss.l*hg_ss.l);
perc_n(it) = (sum(ind,n_ss_ct.l(ind))+ng_ss_ct.l-sum(ind,n_ss.l(ind))-ng_ss.l)/(sum(ind,n_ss.l(ind))+ng_ss.l);


tbal_ss_db(it) = sum(ind,p_ss_ct.l(ind)*exports_ss_ct.l(ind) - (p_f_ss_ct.l(ind)/exch_ss_ct.l)*imports_ss_ct.l(ind)) ;
mc_ss_db(ind,it) = y_ss_ct.l(ind) - cd_ss_ct.l(ind) - gd_ss_ct.l(ind) -  exports_ss_ct.l(ind) - sum(ind2,iod_ss_ct.l(ind,ind2)) ;
bc_ss_db(it) = (1-tau_l.l)*(sum(ind,n_ss_ct.l(ind)*w_ss_ct.l(ind)*h_ss_ct.l(ind)) + ng_ss_ct.l*wg_ss_ct.l*hg_ss_ct.l) + (1-ntot_ss_ct.l)*p_cbar_ss_ct.l*b0.l + p_cbar_ss_ct.l*tlump_ss_ct.l  + sum(ind,prof_ss_ct.l(ind))  - p_cbar_ss_ct.l*cbar_ss_ct.l;
mc_ss_f_db(ind,it) = y_f_ss_ct.l(ind) - cd_f_ss_ct.l(ind) - gd_f_ss_ct.l(ind) -  imports_ss_ct.l(ind) - sum(ind2,iod_f_ss_ct.l(ind,ind2)) ;
bc_ss_f_db(it) = (1-tau_l0)*(sum(ind,n_f_ss_ct.l(ind)*w_f_ss_ct.l(ind)*h_f_ss_ct.l(ind)) + ng_f_ss_ct.l*wg_f_ss_ct.l*hg_f_ss_ct.l) + (ratiof-ntot_f_ss_ct.l)*p_cbar_f_ss_ct.l*b0_f.l + p_cbar_f_ss_ct.l*tlump_f_ss_ct.l  + sum(ind,prof_f_ss_ct.l(ind))  - p_cbar_f_ss_ct.l*cbar_f_ss_ct.l;
yg_ss_db(it) =  gammayg0.l*( alphapg.l*(hg_ss_ct.l*ng_ss_ct.l*(1-vbarg_ss_ct.l))**rhog + (1-alphapg.l)*vvg_ss_ct.l**rhog)**(1/rhog) - yg0;
yg_ss_f_db(it) =  gammayg0_f.l*( alphapg_f.l*(hg_f_ss_ct.l*ng_f_ss_ct.l*(1-vbarg_f_ss_ct.l))**rhog + (1-alphapg_f.l)*vvg_f_ss_ct.l**rhog)**(1/rhog) - yg0_f;
sub_ss_db(ind,it) = sum(ie,p_e_ss(ie,ind)*mu_e(ie,ind)*(iod_ss_ct.l(ie,ind)+iof_ss_ct.l(ie,ind)) + tar_i2(ie)*p_e_ss(ie,ind)*iof_ss_ct.l(ie,ind) )- p_ss_ct.l(ind)*sub_ss_ct.l(ind)*y_ss_ct.l(ind);


* SAVE TRANSITION DATA

tbal_db(t,it) = sum(ind,p.l(ind,t)*exports.l(ind,t) - (p_f.l(ind,t)/exch.l(t))*imports.l(ind,t)) ;
mc_db(ind,t,it) = y.l(ind,t) - cd.l(ind,t) - gd.l(ind,t) -  exports.l(ind,t) - sum(ind2,iod.l(ind,ind2,t)) ;
bc_db(t,it) = (1-tau_l.l)*(sum(ind,n.l(ind,t)*w.l(ind,t)*h.l(ind,t)) + ng.l(t)*wg.l(t)*hg.l(t)) + (1-ntot.l(t))*p_cbar.l(t)*b0.l + p_cbar.l(t)*tlump.l(t)  + sum(ind,prof.l(ind,t))  - p_cbar.l(t)*cbar.l(t);
mc_f_db(ind,t,it) = y_f.l(ind,t) - cd_f.l(ind,t) - gd_f.l(ind,t) -  imports.l(ind,t) - sum(ind2,iod_f.l(ind,ind2,t)) ;
bc_f_db(t,it) = (1-tau_l0)*(sum(ind,n_f.l(ind,t)*w_f.l(ind,t)*h_f.l(ind,t)) + ng_f.l(t)*wg_f.l(t)*hg_f.l(t)) + (ratiof-ntot_f.l(t))*p_cbar_f.l(t)*b0_f.l + p_cbar_f.l(t)*tlump_f.l(t)  + sum(ind,prof_f.l(ind,t))  - p_cbar_f.l(t)*cbar_f.l(t);
yg_db(t,it) =  gammayg0.l*( alphapg.l*(hg.l(t)*ng.l(t)*(1-vbarg.l(t)))**rhog + (1-alphapg.l)*vvg.l(t)**rhog)**(1/rhog) - yg0;
yg_f_db(t,it) =  gammayg0_f.l*( alphapg_f.l*(hg_f.l(t)*ng_f.l(t)*(1-vbarg_f.l(t)))**rhog + (1-alphapg_f.l)*vvg_f.l(t)**rhog)**(1/rhog) - yg0_f;


ndiff(ind,t) = (n.l(ind,t) - n_ss_ct.l(ind))/n_ss_ct.l(ind);
ngdiff(t) = (ng.l(t) - ng_ss_ct.l)/(ng_ss_ct.l);
nfdiff(ind,t) = (n_f.l(ind,t) - n_f_ss_ct.l(ind))/n_f_ss_ct.l(ind);
nfgdiff(t) = (ng_f.l(t) - ng_f_ss_ct.l)/ng_f_ss_ct.l;

utot(t,it) = 1-ntot.l(t);
utot_f(t) = (ratiof-ntot_f.l(t))/ratiof;

utot_diff(t,it) = utot(t,it)-utot_ss_ct(it);
sub_it(ind,t,it) = sub.l(ind,t) - sub_ss_ct.l(ind);
tau_l_d(it) = tau_l.l - tau_l0;
perct_l(t,it) = (sum(ind,l_ct(ind,t))+lg_ct(t)-sum(ind,l_ss(ind))-lg_ss)/(sum(ind,l_ss(ind))+lg_ss);
perct_h(t,it) = (sum(ind,n_ss.l(ind)*h.l(ind,t))+ng_ss.l*hg.l(t)-sum(ind,n_ss.l(ind)*h_ss.l(ind))-ng_ss.l*hg_ss.l)/(sum(ind,n_ss.l(ind)*h_ss.l(ind))+ng_ss.l*hg_ss.l);
perct_w(t,it) =  (  (sum(ind,n_ss.l(ind)*w.l(ind,t))+ng_ss.l*wg.l(t))/p_cbar.l(t)-(sum(ind,n_ss.l(ind)*w_ss.l(ind))+ng_ss.l*wg_ss.l)/p_cbar_ss )/( (sum(ind,n_ss.l(ind)*w_ss.l(ind))+ng_ss.l*wg_ss.l)/p_cbar_ss);
perct_earn(t,it) = (  (sum(ind,n_ss.l(ind)*w.l(ind,t)*h.l(ind,t))+ng_ss.l*wg.l(t)*hg.l(t) )/p_cbar.l(t)-(sum(ind,n_ss.l(ind)*w_ss.l(ind)*h_ss.l(ind))+ng_ss.l*wg_ss.l*hg_ss.l )/p_cbar_ss    )   / ( (sum(ind,n_ss.l(ind)*w_ss.l(ind)*h_ss.l(ind))+ng_ss.l*wg_ss.l*hg_ss.l )/p_cbar_ss);

if(ord(it) = 4,
execute_unload 'out_jaere_trans_ct40_lump.gdx'
);




);


* DISPLAY KEY RESULTS

display
utot_ss_ct
n_d_perc
l_d_perc
h_d_perc
ng_d_perc
lg_d_perc
hg_d_perc
perc_e_y
perc_e_elec
perc_e
perc_n
perc_h
perc_l
tau_l.l
vlump_d.l
sub_ss_ct.l


tbal_ss_db
mc_ss_db
bc_ss_db
mc_ss_f_db
bc_ss_f_db
yg_ss_db
yg_ss_f_db
sub_ss_db

tbal_db
mc_db
bc_db
mc_f_db
bc_f_db
yg_db
yg_f_db

ndiff
ngdiff
nfdiff
nfgdiff

utot
utot_f
utot_diff
tau_l_d
sub_it


;

parameter


figure_HWC_LUMP_T(*,t,it)

;

figure_HWC_LUMP_T('out1',t,it) = utot(t,it)-.05;
figure_HWC_LUMP_T('out2',t,it) = perct_l(t,it);
figure_HWC_LUMP_T('out3',t,it) = perct_h(t,it);
figure_HWC_LUMP_T('out4',t,it) = perct_w(t,it);
figure_HWC_LUMP_T('out5',t,it) = perct_earn(t,it);

execute_unload "figure_JAERE_HWC_LUMP_T.gdx"     figure_HWC_LUMP_T
execute 'gdxxrw.exe figure_JAERE_HWC_LUMP_T.gdx  o=figure_JAERE_HWC_LUMP_T.xls SQ=N par=figure_HWC_LUMP_T rng=figure_HWC_LUMP_T!'
